import { ApiCall } from "tsrpc";
import { ReqOpen_dnaLock_1, ResOpen_dnaLock_1 } from "../../../../shared/master/bag/function/PtlOpen_dnaLock_1";
import { player } from "../../../../model/fight/body/player";
import app from "../../../../app";
import { template } from "../../../../shared/master/MsgAction";

export default async function (call: ApiCall<ReqOpen_dnaLock_1, ResOpen_dnaLock_1>) {
    call.succ({})
    if (call.req.num <= 0) {
        call.req.num = 1;
    }
    let user = call.req._player as player;

    let res = user.check_wallet(0, 0, [{ id: 'prop-16', v: call.req.num }], false, '使用T病毒原型', true);
    if (!res.state) {
        return;
    }
    if(user.get_DNA_Lv() != 0){
        user.sendMsg(template.default,"病毒原型效果融合失败")
        return;
    }
    let rang = call.req.num * 10;
    if(rang > app.random(0,100)){
        user.upLeve_dna()
    }else{
        user.sendMsg(template.default,"病毒原型效果融合失败")
    }
}